package com.itheima.test5;

public class PhoneTest {
    public static void main(String[] args) {
        //1.定义数组存储手机对象
        Phone[] arr=new Phone[3];
        //2.定义三个手机对象
        Phone p1=new Phone("小米",1999,"白色");
        Phone p2=new Phone("华为",4999,"黑色");
        Phone p3=new Phone("荣耀",3999,"蓝色");
        arr[0]=p1;
        arr[1]=p2;
        arr[2]=p3;
        //求三部手机的总和
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum=sum+arr[i].getPrice();
        }

        //求平均值
        double avg=sum*1.0/ arr.length;
        System.out.println(avg);
    }
}
